#ifndef SUBGAMEDATA_H
#define SUBGAMEDATA_H

#include "lib.h"
#include <vector>

using namespace std;

struct SubGameData
{
    uint8 id;
    int64 data;
    bool8 serverOnly;
};




class SubGame
{
    public:
        SubGame(uint8 machid, String& pid, int32 creditValue, bool8 forMoney);
        ~SubGame();

        void update(uint8 id, int64 data);
        void setServerOnly(uint8 id, bool8 serverOnly);

        int32 getDataCount();
        int64 getData(uint8 id);
        bool8 isServerOnly(uint8 id);


        /**
         * The AT methods should used by something that needs
         * to iterate the subgame data.  All normal access should
         * be via id only.
         */
        int64 getDataAt(int32 index);

        /**
         * The AT methods should used by something that needs
         * to iterate the subgame data.  All normal access should
         * be via id only.
         */
        int32 getIdAt(int32 index);

        /**
         * The AT methods should used by something that needs
         * to iterate the subgame data.  All normal access should
         * be via id only.
         */
        bool8 isServerOnlyAt(int32 index);

        uint8 getClientOnlyDataSize();


        uint8 getMachid();
        String& getPid();
        int32 getCreditValue();
        bool8 isForMoney();


    private:
        uint8 m_machid;
        String m_pid;
        int32 m_creditValue;
        bool8 m_forMoney;
        typedef vector<SubGameData *> SubGameArray;
        SubGameArray m_array;

        void add(uint8 id, int32 data, bool8 serverOnly = false);

};




#endif

